package net.projecteuler.problem5;

public class SmallestMultiple {
	
	public boolean isDividedByEachNumber(long testNumber, int countDiv) {
		for (int j = countDiv; j >= 2; j--) {
			if(testNumber % j != 0)
				return false;
		}
		return true;
	}
	
	public long getSmallestMultiple(int countDiv) {
		long limit = 1;
		for (int i = 1; i <= countDiv; i++) {
			limit *= i;
		}
		
		long testNumber = countDiv;
		while (testNumber < limit) {
			if (isDividedByEachNumber(testNumber, countDiv)) {
				return testNumber;
			}
			testNumber += countDiv;
		}
		return 0;
	}
}
